//
//  GameSelectController.m
//  DigitalFlip
//
//  Created by 蓝鳍互娱 on 2024/1/23.
//

#import "GameSelectController.h"
#import "Public.h"
#import "GameSelctCollectionCell.h"
@interface GameSelectController ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic,strong) UICollectionView *gameSelectCollectionView;
@end
@implementation GameSelectController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = UIColor.whiteColor;
    [self creatSubView];
}
- (void)creatSubView{
    UICollectionViewFlowLayout* gameSelectFlowLayout = [[UICollectionViewFlowLayout alloc] init];
    gameSelectFlowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    self.gameSelectCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:gameSelectFlowLayout];
    [self.gameSelectCollectionView registerClass:[GameSelctCollectionCell class] forCellWithReuseIdentifier:@"GameSelctCollectionCell"];
    self.gameSelectCollectionView.backgroundColor = UIColor.clearColor;
    self.gameSelectCollectionView.delegate = self;
    self.gameSelectCollectionView.dataSource = self;
    [self.view addSubview:self.gameSelectCollectionView];
    [self.gameSelectCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@(ScreenAutoScale(0)));
    }];
}
#pragma mark -- UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 150;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    CGFloat itemW = (ScreenW - ScreenAutoScale(30)- ScreenAutoScale(30))/5;
    CGSize ItemSize = CGSizeMake(itemW,itemW);
    return ItemSize;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    GameSelctCollectionCell *gameSelctCollectionCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"GameSelctCollectionCell" forIndexPath:indexPath];
    gameSelctCollectionCell.indexNo = [NSString stringWithFormat:@"%zd",indexPath.row+1];
    return gameSelctCollectionCell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
//    if([self.memoryTrainGameSelectIndex intValue] >= indexPath.row){//没上锁
//        MemoryTrainGameController * memoryTrainGameCtrl = [[MemoryTrainGameController alloc] init];
//        memoryTrainGameCtrl.memoryTrainStartGameType = self.memoryTrainStartGameType;
//        memoryTrainGameCtrl.memoryTrainGameSelectIndex = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
//        [self.navigationController pushViewController:memoryTrainGameCtrl animated:YES];
//    }
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    UIEdgeInsets caloriesBurnedSectionEdgeInsets = UIEdgeInsetsZero;
    caloriesBurnedSectionEdgeInsets = UIEdgeInsetsMake(0, 15, 0, 15);
    return caloriesBurnedSectionEdgeInsets;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    return 10;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
    return 10;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
